﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Hook.Environmental.Props;

namespace Hook.Environmental
{
    public class HingeLink
    {
        public Prop Prop1, Prop2;
        public Vector3 HingeOffset1, HingeOffset2;

        public HingeLink(Prop P1, Vector3 O1, Prop P2, Vector3 O2)
        {
            Prop1 = P1;
            Prop2 = P2;
            HingeOffset1 = O1;
            HingeOffset2 = O2;
        }

        public void AdjustHingePositions()
        {
            Vector3 Distance, HingeLocation1, HingeLocation2;
            HingeLocation1 = Prop.RotateVectorAboutZ(HingeOffset1, Prop1.Rotation.Z);
            HingeLocation2 = Prop.RotateVectorAboutZ(HingeOffset2, Prop2.Rotation.Z);
            Distance = (Prop2.Position + HingeLocation2) - (Prop1.Position + HingeLocation1);

            //Prop1.SetPosition(Prop1.Position + Distance / 2);
            Prop2.SetPosition(Prop2.Position - Distance);
        }
    }
}
